package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.result.Result;
import com.sky.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrdersController")
@RequestMapping("/admin/order")
@Api(tags = "订单管理相关接口")
public class OrdersController {

    @Autowired
    private OrdersService ordersService;

    @GetMapping("/conditionSearch")
    @ApiOperation("订单搜索")
    public Result conditionSearch(OrdersPageQueryDTO ordersPageQueryDTO){
        return ordersService.conditionSearch(ordersPageQueryDTO);
    }

    @GetMapping("/details/{id}")
    @ApiOperation("查看订单详情")
    public Result getOrdersDetails(@PathVariable String id){
        return ordersService.getOrdersDetails(id);
    }

    @GetMapping("/statistics")
    @ApiOperation("各个状态的订单数量统计")
    public Result statistics(){
        return ordersService.statistics();
    }

    @PutMapping("/confirm")
    @ApiOperation("接单")
    public Result confirm(@RequestBody OrdersConfirmDTO ordersConfirmDTO){
        return ordersService.confirm(ordersConfirmDTO);
    }

    @PutMapping("/rejection")
    @ApiOperation("拒单")
    public Result rejection(@RequestBody OrdersRejectionDTO ordersRejectionDTO){
        return ordersService.rejection(ordersRejectionDTO);
    }

    @PutMapping("/cancel")
    @ApiOperation("取消订单")
    public Result cancel(@RequestBody OrdersCancelDTO ordersCancelDTO){
        return ordersService.cancelByAdmin(ordersCancelDTO);
    }

    @PutMapping("/delivery/{id}")
    @ApiOperation("派送订单")
    public Result deliveryOrders(@PathVariable String id){
        return ordersService.deliveryOrders(id);
    }

    @PutMapping("complete/{id}")
    @ApiOperation("完成订单")
    public Result completeOrders(@PathVariable String id){
        return ordersService.completeOrders(id);
    }


}
